function submitCommentForm(ev)
{
    ev.preventDefault();
    $("#submitCommentForm").attr('disabled', 'disabled');
    var id = $("#Entry_Id").val();
    var type = $("#Entry_Type").val();
    var dataString = $('#commentForm').serialize();

    $.ajax(
            {
                type: "POST",
                data: dataString,
                url: $("#commentForm").attr("action") + "/" + type + "/" + id,
                success: function (result) {
                    $("#commentscontainer").html(result);
                    $("#commentForm").submit(submitCommentForm);
                },
                error: function (result) {
                    $("#submitCommentForm").removeAttr('disabled');
                }
            });
}

function printPage(ev)
{
    ev.preventDefault();

    var css = document.styleSheets[0];
    var cssRules = css.cssRules;
    if (cssRules) {
        for (var i = 0; i < cssRules.length; i++) {
            var rule = cssRules[i];

            if (rule.media && rule.media.mediaText == 'print') {
                for (var j = 0; j < rule.cssRules.length; j++) {
                    css.insertRule(rule.cssRules[j].cssText, cssRules.length);
                }
                break;
            }
        }
    }

    window.print();
}

$(function () {

    $("#commentForm").submit(submitCommentForm);

    //$("#printButton").click(printPage);

});